<?php
$username = $_POST['username'];
$password = $_POST['password'];


$mysql_host = "mysql16.000webhost.com";
$mysql_database = "a1863493_venture";
$mysql_user = "a1863493_teamven";
$mysql_password = "teamventure1";

if( $email1 != $email2 )
{
	echo "emails don't match";
}
else // connected here V
{
	$link = mysql_connect($mysql_host, $mysql_user, $mysql_password); 
	
	if (!$link) 
	{
		die('Could not connect: ' . mysql_error());
	} 
	echo 'Connected successfully'; 
	mysql_select_db($mysql_database, $link) or die ("Fail");
	
	// Find a username and password match
	// Then start a session and load the correct page
	
	$query = sprintf("SELECT name FROM cust_acct WHERE name = '$username' AND pass = '$password'");
	$return = mysql_query($query);
	if (mysql_num_rows($return)){
		$result = mysql_result($return,0);		
	
	if( $result )		
	{
		// start session with username set USER
		session_start();
		// store session data
		$_SESSION['username'] = $username;
		header ('Location: ../userHomepage.html');
	}
	}
	else
	{
		$query = sprintf("SELECT name FROM bus_acct WHERE name = '$username' AND pass = '$password'");
		$return = mysql_query($query);
		if (mysql_num_rows($return)){
			$result = mysql_result($return,0);		
		}
		if( $result )		
		{
			// start session with username set BUSINESS
			session_start();
			// store session data
			$_SESSION['username'] = $username;
			header ('Location: ../bushome.html');
		}
		else
		{
			// no username/password match
			echo "No username/password match";
			header ('Location: ../index.html');
		}	
	}		
}




?>